package com.ycode.bang.anbang.utils;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ycode.bang.anbang.R;


/**
 * 带x号的dialog,蠢显示字
 */
public class DialogWithDelete2 {

    private static AlertDialog dialog;

    private Context mContext;


    public static void showSimpleDialog(final Context mContext) {
        dismiss();
        dialog = null;
        View view = LayoutInflater.from(mContext).inflate(R.layout.dialog_delete, null);
        TextView message = (TextView) view.findViewById(R.id.Dialog_message);
        ImageView delete = (ImageView) view.findViewById(R.id.delete);
        TextView message1 = (TextView) view.findViewById(R.id.Dialog_message1);

        AlertDialog.Builder builder = new AlertDialog.Builder(mContext, android.R.style.Theme_Holo_Light_Dialog);
        dialog = builder.create();
        dialog.setCanceledOnTouchOutside(false);

        dialog.getWindow().setBackgroundDrawableResource(R.drawable.transparent_bg);
        dialog.setCancelable(true);//返回键

        dialog.show();

        dialog.setContentView(view);

//        message.setText(massage);
        delete.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
                ((Activity) v.getContext()).finish();
            }
        });
//        message1.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                Intent intent = new Intent(mContext, SelectPeopleActivity.class);
//                mContext.startActivity(intent);
//                dialog.dismiss();
//            }
//        });
    }

    public static void dismiss() {
        if (dialog != null && dialog.isShowing()) {
            dialog.dismiss();
            dialog = null;
        }
    }
}
